package com.risen.project.enums;

import java.util.Arrays;
import java.util.Optional;

/**
 * 建设层级枚举
 */
public enum ConstructionHierarchyEnum {

    CHE_NATIONAL("G", "国家级"),

    CHE_PROVINCIAL("P", "省级"),

    CHE_PROVINCIAL_SAME("PP", "省本级"),

    CHE_CITY("M", "市级"),

    CHE_CITY_SAME("MM", "市本级"),

    CHE_COUNTY("C", "区县"),

    CHE_STREET("T", "乡镇（街道）")
    ;


    private final String code;
    private final String msg;

    ConstructionHierarchyEnum(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static String getMsgByCode(String code) {
        Optional<ConstructionHierarchyEnum> optional = Arrays.stream(values())
                .filter(c -> c.code.equals(code))
                .findFirst();

        return optional.isPresent() ? optional.get().msg : "";
    }
}
